package de.szut.fragments.dialogs;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import de.szut.scene.scenes.GameScene;
import de.szut.splasher.R;

/**
 * Created with IntelliJ IDEA.
 * User: nbothmer
 * Date: 30.10.13
 * Time: 14:01
 * To change this template use File | Settings | File Templates.
 */
public class GameWonDialog extends DialogFragment {

    private GameScene gameScene;
    private Button finishBtn;
    private Dialog mDialog;

    public GameWonDialog(){}

    public GameWonDialog(GameScene gameScene) {
        this.gameScene = gameScene;
    }

    public static GameWonDialog newInstance(GameScene gameScene) {
        GameWonDialog dlg = new GameWonDialog(gameScene);
        return dlg;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.game_won_dialog,container,false);
        mDialog = getDialog();
        mDialog.setCancelable(false);
        mDialog.setTitle(R.string.game_won);
        mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        finishBtn = (Button) root.findViewById(R.id.game_won_finish_btn);
        finishBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gameScene.exitGame();
            }
        });
        return root;
    }

    @Override
    public void onResume() {
        super.onResume();    //To change body of overridden methods use File | Settings | File Templates.
    }
}
